
	<table id="data"></table>
	<div id="bombBox" ></div>

	<script type="text/javascript">
		
		(function($){

			setTimeout("data()",100); 
		})(jQuery);

		// 数据查询
		function data(){

			$('#data').datagrid({    
		    	url:'/daoOwnerFeeStandard/ownerFeeStandardJsonSeleft',
				method:'post',
				fit:true,
				fitColumns:true,
				striped:true,
				border:false,
				pagination:true,
				rownumbers:false,
				toolbar:'#query',
				singleSelect:true,
				pageSize:30,//每页显示的记录条数，默认为10 
		        pageList:[10,20,30,40,50,500,1000],//可以设置每页记录条数的列表 
			    columns:[

			    	[
			    		{"title":"序号","colspan":1},
			    		{"title":"业主","colspan":2},
			    		{"title":"房产","colspan":5},
			    		{"title":"业主收费标准","colspan":1},
			    		{"title":"信息","colspan":1},
			    		{"title":"管理","colspan":1},
			    	],
			    	[
			    		{field:'id',title:'id',width:20,align:'center'},	    	 
			    		{field:'phone',title:'租户手机号',width:40,align:'center',},
			    		{field:'fullName',title:'租户姓名',width:40,align:'center',},
			    		{field:'cellName',title:'小区名称',width:40,align:'center'},
			    		{field:'buildingName',title:'栋名称',width:40,align:'center'},
			    		{field:'roomNumber',title:'房号',width:40,align:'center'},
			    		{field:'rent',title:'租金',width:40,align:'center'},
			    		{field:'face',title:'平方',width:40,align:'center'},
						{field:'chargeForWaterDisplay',title:'显示',width:60,align:'center',
						 	formatter:function(value, row, index){

						 		var chargeForWater = row.chargeForWater;
						 		var electricityFees = row.electricityFees;
						 		var managementExpense = row.managementExpense;
						 		var repairFee = row.repairFee;
						 		var networkFee = row.networkFee;
						 		var garbageFee = row.garbageFee;
						 		var gasDeposit = row.gasDeposit;
						 		var liquidatedDamages = row.liquidatedDamages;
						 		var deposit = row.deposit;

						 		var str;
								str = "<div style='text-align:left;'>"
									+"<table>"
									+	"<tr>"
									+		"<td>水费：</td>"
									+		"<td>"+chargeForWater+"</td>"
									+		"<td>电费：</td>"
									+		"<td>"+electricityFees+"</td>"
									+	"</tr>"
									+	"<tr>"
									+		"<td>管理费：</td>"
									+		"<td>"+managementExpense+"</td>"
									+		"<td>报修费：</td>"
									+		"<td>"+repairFee+"</td>"
									+	"</tr>"
									+	"<tr>"
									+		"<td>网络费：</td>"
									+		"<td>"+networkFee+"</td>"
									+		"<td>垃圾费：</td>"
									+		"<td>"+garbageFee+"</td>"
									+	"</tr>"
									+	"<tr>"
									+		"<td>煤气押金：</td>"
									+		"<td>"+gasDeposit+"</td>"
									+		"<td>违约金：</td>"
									+		"<td>"+liquidatedDamages+"</td>"
									+	"</tr>"
									+	"<tr>"
									+		"<td>定金：</td>"
									+		"<td>"+deposit+"</td>"
									+		"<td></td>"
									+		"<td></td>"
									+	"</tr>"
									+"</table>"
								+"</div>";
								return str;
						 	}
						},
			    		{field:'createTime',title:'创建时间',width:40,align:'center'},
						{field:'operation',title:'操作',width:30,align : 'center', 
							formatter:function(value,row,index){
							 	var id= row.id; 
								var str = "<button class='btn btn-default btn-xs' style='margin:2px;' onClick='saveData("+id+")'>编辑</button>&nbsp;"
									    + "<button class='btn btn-default btn-xs' style='margin:2px;' onClick='saveStatus("+id+","+-100+")'>删除</button>"
								return str;
							}
						}
			    	],
			    ],
				onLoadError:function(info){

				},
				onLoadSuccess:function(info){

					// setTimeout("doAdd()",10);
				},
				
			});  

			var p = $('#data').datagrid('getPager'); 
		    $(p).pagination({ 
		        beforePageText:'第',//页数文本框前显示的汉字 
		        afterPageText:'页 共 {pages} 页', 
		        displayMsg:'当前显示 {from} - {to} 条记录 共 {total} 条记录', 
				buttons:[{
					iconCls:'icon-add',
					handler:function(){
						doAdd();
					}
				},'-',{
					iconCls:'icon-help',
					handler:function(){
						alert('help');
					}
				}]
		    }); 
		} 

		// 状态更新
		function saveStatus(id, num){

			$.messager.confirm('确认','您确认想要执行吗？',function(r){    
				if(r){
			    	$.messager.progress({msg:'正在执行...',interval:3000,});
					$.ajax({
						type: "post",
						url: "/daoOwnerFeeStandard/ownerFeeStandardSaveStatus",
						data:{
							id:id,
							num:num,
						},
						cache: false,
						dataType:'html',
						success: function(data){
							var data = eval('('+data+')');
							if( data.info == 'success' ){
								
								$.messager.progress('close');
								$('#action').dialog('close');
								$('#data').datagrid('reload');   
							} else {
								
								$.messager.progress('close');
								$.messager.alert('提示信息', data.info);
							}
						}
					});
				}
			});
		}

		// 数据更新
		function saveData(id){

			$.messager.progress({msg:'正在查询...',interval:3000,});
			$.ajax({
				type:"post",
				url:"/daoOwnerFeeStandard/ownerFeeStandardIdSelect",
				data:{
					id:id,
				},
				cache: false,
				dataType:'html',
				success:function(data){

					var data = eval('('+data+')');
					if( data.info != 'success' ){
						
						$.messager.progress('close');
						$.messager.alert('提示信息', data.info);
					} else {
						
						$.messager.progress('close');
						doAdd(id, data.rows);
					}
				}
			});
		}

	</script>
